<?php

namespace common\model;

use think\model\RelationModel;

class TaskWorkOrderProblemStepCategoryModel extends RelationModel
{
    const IS_CONFIRM_DEFAULT = 'default';
    const IS_CONFIRM_YES = 'yes';
    const IS_CONFIRM_NO = 'no';

    //自动验证
    protected $_validate = [
        ['task_work_order_id', '', '', self::MUST_VALIDATE, 'require', self::MODEL_INSERT],
        ['task_work_order_id', '', '', self::EXISTS_VALIDATE, 'integer'],
        ['step_category_id', '', '', self::MUST_VALIDATE, 'require', self::MODEL_INSERT],
        ['step_category_id', '', '', self::EXISTS_VALIDATE, 'integer'],
        ['plan_end_time', '', '', self::EXISTS_VALIDATE, 'integer'],
        ['confirm_person', '', '', self::EXISTS_VALIDATE, 'integer'],
        ['is_confirm', ['default', 'yes', 'no'], '', self::EXISTS_VALIDATE, 'in'],
        ['task_work_order_id,step_category_id', '', '', self::MUST_VALIDATE, 'unique'], // 联合唯一
    ];

    //自动完成
    protected $_auto = [
        ['uuid', 'create_uuid', self::MODEL_INSERT, 'function'],
        ['created_by', 'fill_created_by', self::MODEL_INSERT, 'function'],
        ['created', 'time', self::MODEL_INSERT, 'function'],
    ];
}